<template>
  <div class="travelers">
    <div class="addtravelers">
      <span
      @click="back"
        class="iconfont icon-fanhui"
      ></span>
     <div @click="add"> 添加出游人</div>
    </div>

    <div class="ul" v-for="item in arr" :key="item.number">
      <div class="li">
        <img src="../../public/img/edit.png" alt="" />
        <div class="name">{{ item.name }}</div>
        <div class="age">{{ item.age }}</div>
      </div>
      <div class="number">电话：{{ item.number }}</div>
      <div class="remov iconfont icon-shanchu" @click="remov(item.number)"></div>
    </div>

    <transition>
      <div class="add_travelers" v-if="edit">
        <div class="account_login">
            <div class="no_add" @click="mask">X</div>
          <div class="uname"><input type="text" v-model="name" placeholder="姓名" /></div>
          <div class="uname"><input type="text" v-model="number" placeholder="手机号码" /></div>
          <div class="uname"><input type="text" value="身份证" placeholder="证件信息" /></div>
          <div class="uname"><input type="text" v-model="idNumber" placeholder="证件号码" /></div>
          <div class="account" @click="okadd">确认</div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [
        {
          name: "张三",
          age: "成人",
          number: 19152403312,
        },
      ],
      edit:false,
      name:'',
      number:'',
      idNumber:'',
    };
  },
  methods: {
    back(){
      this.$router.back()
    },
    add() {
        this.edit = true
    },
    mask(){
        this.edit = false
    },
    okadd(){
       if (this.name&&this.number&&this.idNumber) {
         this.arr.push({
            name:this.name,
            age:"成人",
            number:this.number
        });
       }
        this.name=this.age=this.number=null;
        this.edit = false
    },
    remov(id){
        let index = this.arr.findIndex(item => item.number==id);
        this.arr.splice(index,1)
    }
  },
};
</script>

<style lang="scss" scoped>
.travelers {
  background-color: #f5f5f5;
  border-top: 1px solid #f5f5f5;
  width: 100%;
  height: 100%;
  position: relative;
  .add_travelers {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.312);
    z-index: 9;
    .account_login{
    z-index: 10;
    border-radius: 6px;
    background-color: #fff;
    margin: 100px 19px 0 19px;
    padding-top: 10px;
    padding-bottom: 30px;
    position: relative;
    .no_add{
        position: absolute;
        top: 0;
        margin-right: 15px;
        margin-top: 10px;
        right: 0;
        color: #ccc;
    }
    .uname{
        height: 56px;
        margin-left: 10px;
        border-bottom: 1px solid #eee;
        input{
            height: 56px;
            margin-left: 10px;
            
            border:none;
            
        }
    }
    .account {
      margin-top: 33px;
      margin-right: 20px;
      margin-left: 20px;
      border-radius: 6px;
      height: 44px;
      text-align: center;
      color: #fff;
      background-color: #80d7d1;
      
      line-height: 44px;
    }
    
  }
  }
  .ul {
    background-color: #fff;
    position: relative;
    margin-bottom: 10px;
    .remov {
      position: absolute;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      margin-right: 20px;
      font-size: 24px;
      color: #aaa;
    }
    .number {
      margin-left: 43px;
      color: #333;
      font-size: 14px;
      margin-top: 5px;
      padding-bottom: 10px;
    }
    .li {
      padding-top: 15px;
      margin-left: 15px;
      display: flex;
      align-items: center;
      .age {
        font-size: 12px;
        color: #999;
        margin-left: 8px;
      }
      .name {
        color: #333;
        font-size: 16px;
        margin-left: 15px;
      }
      img {
        width: 13px;
        height: 13px;
      }
    }
  }
  .addtravelers {
    margin: 10px 0;
    height: 55px;
    text-align: center;
    line-height: 55px;
    color: #80d7d1;
    background-color: #fff;
    position: relative;
    span {
      position: absolute;
      left: 10px;
      height: 55px;
      font-size: 24px;
    }
  }
  
  
}
</style>